package com.ad.pet.app.mall.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ad.pet.R;
import com.ad.pet.models.remote.mall.Value;

import java.util.List;

/**
 * Created by SEELE on 2019/5/14.
 */

public class SkuItemAdapter extends BaseQuickAdapter<Value, BaseViewHolder> {
    public SkuItemAdapter(@Nullable List<Value> data) {
        super(R.layout.item_sku_text_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, Value item) {
        TextView tvName = helper.getView(R.id.tv_name);
        tvName.setText(item.getName());
        if (item.isChose()){
            tvName.setTextColor(mContext.getResources().getColor(R.color.colorAccent));
            tvName.setBackgroundResource(R.drawable.btn_text_select_sku);
        }else {
            tvName.setTextColor(mContext.getResources().getColor(R.color.black3d));
            tvName.setBackgroundResource(R.drawable.shap_bg_bgcoloer);
        }
    }

    public String getChoseItem() {
        String string = "";
        for (int i = 0; i < mData.size(); i++) {
            string = mData.get(i).getName();
        }
        return string;
    }

    public void setChoseItem(int position) {
        for (int i = 0; i < mData.size(); i++) {
            if (position == i) {
                mData.get(i).setChose(true);
            } else {
                mData.get(i).setChose(false);
            }
        }
    }
}
